0e7c3a
@@ -88,7 +88,9 @@
public ByteArrayOutputStream(int size) {
             throw new IllegalArgumentException(
                 "Negative initial size: " + size);
         }
-        needNewBuffer(size);
+        synchronized (this) {
+            needNewBuffer(size);
+        }
     }
 
     /**
